UserProfileTabs.tsx 892 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use client';
  2. import Link from 'next/link';
  3. import { useSelectedLayoutSegment } from 'next/navigation';
  4. type Props = {
  5. memberSID: string;
  6. };
  7. export default function UserProfileTabs({ memberSID }: Props) {
  8. const segment = useSelectedLayoutSegment();
  9. const tabs = [
  10. { key: null, label: '게시글', href: `/user/${memberSID}` },
  11. { key: 'comments', label: '댓글', href: `/user/${memberSID}/comments` },
  12. { key: 'feed', label: '피드', href: `/user/${memberSID}/feed` }
  13. ];
  14. return (
  15. <nav className="user-profile__tabs" aria-label="프로필 탭">
  16. {tabs.map((tab) => {
  17. const active = segment === tab.key;
  18. return (
  19. <Link
  20. key={tab.label}
  21. href={tab.href}
  22. className={`user-profile__tab${active ? ' user-profile__tab--active' : ''}`}
  23. aria-current={active ? 'page' : undefined}
  24. >
  25. {tab.label}
  26. </Link>
  27. );
  28. })}
  29. </nav>
  30. );
  31. }